package com.qf.springboot.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * projectName: springboot
 *
 * @author dongshihao
 * Date:2021/9/11   22:22
 * description:
 */
@Configuration  //<Bean>
@EnableSwagger2
public class Swagger2Config {

    /**
     * Swagger2在线文档描述信息
     *
     * @return
     */
    @Bean //<bean id = 方法名 class=方法返回结果类型>
    public ApiInfo apiInfo(){
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("董世豪的swagger2 在线文档入门")
                .description("董世豪的性感文档测试接口")
                .version("v1..1")
                .contact(new Contact("董世豪", "http://www.baidu.com", "3090930041@qq.com"))
                .build();

        return apiInfo;

    }

    /**
     * 指定那些包下controller 和那些路径资源需要生产文档在swagger中
     * @return
     */
    @Bean //  <bean>
    public Docket docker(ApiInfo apiInfo){
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .select()  // 所有
                .build();
        return docket;
    }

}
